<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        html, body, #app {
            height: 100%;
        }
        .mark{
            position: absolute;
            top: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, .5);
        }
        .small {
            width: 300px;
            height: 300px;
            margin: auto;
            background: #fff;
            margin-top: 300px;
            padding: 20px;
        }
    </style>
</head>

<body>
    <div id="app">
        <button @click="flag = true">显示弹框</button>
        <div>
            <p v-for="item in list" v-show="item.flag">
                {{ item.title }}
            </p>
        </div>
        <marks @changeflag="fn" v-show="flag" />
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>


    <template id="mark">
        <div class="mark">
            <div class="small">
                <ul>
                    <li v-for="(item, index) in list">
                        <input v-model="item.flag" type="checkbox">
                        {{ item.title }}
                    </li>
                </ul>
                <button @click="sendList">确定</button>
                <button @click="sendFlag">取消</button>
            </div>
        </div>
    </template>
    <script>
        // 子组件弹框
        const Mark = {
            template: "#mark",
            data() {
                return {
                    list: [
                        {
                            title: "篮球",
                            flag: false
                        },
                        {
                            title: "电竞",
                            flag: false
                        },
                        {
                            title: "看书",
                            flag: false
                        }
                    ]
                }
            },
            methods: {
                sendFlag() {
                    this.$emit('changeflag', {
                        flag: false
                    })
                },
                sendList() {
                    this.$emit('changeflag', {
                        flag: false,
                        list: this.list
                    })
                }
            }
        }

        const app = new Vue({
            el: "#app",
            data: {
                flag: false,
                list: []
            },
            components: {
                marks: Mark
            },
            methods: {
                fn(obj) {
                    this.flag = obj.flag
                    this.list = obj.list
                }
            }
        })
    </script>
</body>

</html>